home *** CD-ROM | disk | FTP | other *** search
/ Pascal Super Library / Pascal Super Library (CW International)(1997).bin / LIBRARY / RTPC10 / DISKSUM.PAS < prev    next >
Pascal/Delphi Source File  |  1993-11-20  |  3KB  |  77 lines

  1. {
  2.   ┌────────┬──────────────────────────────────────────────────────┐
  3.   │Name    │ DISKSUM.PAS                                          │
  4.   ├────────┼──────────────────────────────────────────────────────┤
  5.   │Use     │ Just an example program for TP6 and above.           │
  6.   │        │ Lists all the files on current drive.                │
  7.   ├────────┼──────────────────────────────────────────────────────┤
  8.   │By      │ Rafe Aldridge - (C) Copyright 1993                   │
  9.   └────────┴──────────────────────────────────────────────────────┘
  10.   ┌───────────────────────────────────────────────────────────────┐
  11.   │ Please realise that this program present's an idea. No claim  │
  12.   │ is made that it is well written or cannot be improved upon    │
  13.   └───────────────────────────────────────────────────────────────┘
  14.   ┌───────────────────────────────────────────────────────────────┐
  15.   │ Rafe's TP Collection is SHAREWARE                             │
  16.   ├───────────────────────────────────────────────────────────────┤
  17.   │                                                               │
  18.   │ If you find any part of Rafe's TP Collection usefull then     │
  19.   │ please become a registered user by sending 10 Pounds Sterling │
  20.   │ to the address below. In return you will recieve the LATEST   │
  21.   │ FULL source code to ALL the units as well anything new.       │
  22.   │                                                               │
  23.   │ Please feel free to write with suggestions, ideas or money to │
  24.   │     Rafe Aldridge,                                            │
  25.   │     Street Farm,                                              │
  26.   │     Dereham Road,                                             │
  27.   │     Garvestone,                                               │
  28.   │     Norfolk.                                                  │
  29.   │     NR9 4QT                                                   │
  30.   │     ENGLAND                                                   │
  31.   │                                                               │
  32.   └───────────────────────────────────────────────────────────────┘
  33. }
  34.  
  35. uses Dos;
  36.  
  37. var
  38.   NoOfFiles : word;
  39.   NoOfDirec : word;
  40.  
  41. procedure DirList (DirToList : string); { recursive procedure that lists files }
  42. var
  43.   DirInfo: SearchRec;
  44. begin
  45.   FindFirst(DirToList+'*.*', Anyfile, DirInfo);
  46.   while DosError = 0 do
  47.   begin
  48.  
  49.     Write (DirToList+DirInfo.Name+' ');
  50.     write (dirinfo.attr:8);
  51.  
  52.     if (((DirInfo.Attr) and (Directory))=0) then { is it a directory ? }
  53.       begin
  54.         WriteLn;                                    { no }
  55.         Inc (NoOfFiles,1);
  56.       end
  57.     else
  58.       begin
  59.         WriteLn (' - DIRECTORY ');               { yes - is it . or .. ? }
  60.         if (DirInfo.Name<>'.') and (DirInfo.Name<>'..') then { yes }
  61.           begin
  62.             Inc (NoOfDirec,1);
  63.             DirList (DirToList+DirInfo.Name+'\'); { recurse }
  64.           end
  65.       end;
  66.  
  67.     FindNext(DirInfo); { get next file }
  68.   end;
  69. end;
  70.  
  71. begin
  72.   NoOfFiles:=0;  { reset number of files }
  73.   DirList ('\'); { start list at root }
  74.   WriteLn;
  75.   Write (NoOfFiles:0,' Files Found in '); { display number of files }
  76.   Writeln (NoOfDirec:0,' Directories.');
  77. end.